package com.aurora.app.service;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import com.aurora.app.dao.AssessmentDao;
import com.aurora.app.entity.Assessment;
import com.aurora.app.enums.AssessmentType;
import com.aurora.base.dao.BaseDao;
import com.aurora.base.service.BaseService;
@Service
public class AssessmentService extends BaseService<Assessment> {
	@Resource
	private AssessmentDao baseDao;
	
	@Override
	public BaseDao<Assessment> getBaseDao() {
		// TODO 自动生成的方法存根
		return this.baseDao;
	}
	
	/**
	 * 获取某个评论类型的数量
	 * @param userId
	 * @param type
	 * @return
	 */
	@Transactional
	public long getCount(String userId,AssessmentType type){
		Object[] params = new Object[2];
		params[0] = userId;
		params[1] = type.getIndex();
		return this.baseDao.getCount("o.isDelete = 0 and o.thing.user.id = ? and o.assessmentType = ?", params);
	}
}
